package com.yunxi.service.localService.customer.impl;

import com.github.pagehelper.PageInfo;
import com.yunxi.core.enums.DMSEnumsEntity;
import com.yunxi.core.page.PageHelperPlus;
import com.yunxi.core.service.ServiceImplPlus;
import com.yunxi.core.util.BeanTools;
import com.yunxi.core.web.LoginInfo;
import com.yunxi.customer.pojo.CustomerVO;
import com.yunxi.customer.pojo.SatCustomerIntentionVO;
import com.yunxi.dao.customer.CustomerMapper;
import com.yunxi.model.customer.Customer;
import com.yunxi.model.customer.SatCustomerIntention;
import com.yunxi.service.localService.customer.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 客户信息 服务实现类
 * </p>
 *
 * @author 
 * @since 2019-05-09
 */
@Service
public class CustomerServiceImpl extends ServiceImplPlus<CustomerMapper, Customer> implements CustomerService {

   @Autowired
   CustomerMapper customerMapper;

   @Override
   public CustomerVO load(String customerNo , String partnerCode) {
     return customerMapper.load(customerNo,partnerCode);
   }

   /**
    * 获取客户线索信息
    * @param satCustomerIntention
    * @return
    */
   @Override
   public SatCustomerIntentionVO getCustomerClueInfo(SatCustomerIntentionVO satCustomerIntention) {
      return baseMapper.getCustomerClueInfo(satCustomerIntention);
   }

   /**
    * 销售顾问本月新增客户
    * @param customerVO
    * @return
    * @throws Exception
    */
   @Override
   public List<CustomerVO> allList(CustomerVO customerVO) throws Exception {
      return baseMapper.allList(customerVO);
   }

   @Override
   public List<CustomerVO> todayCustomerList(CustomerVO customerVO) throws Exception {
      return baseMapper.todayCustomerList(customerVO);
   }

   @Override
   public CustomerVO getByPhone(String phone , String partnerCode) {
      return baseMapper.getByPhone(phone,partnerCode);
   }

   @Override
   public CustomerVO getCustomerByPhone(String phone, String partnerCode) {
      return baseMapper.getCustomerByPhone(phone,partnerCode);
   }

   @Override
   public String getVehicleNameByVehicleCode(String vehicleCode) {
      return baseMapper.getVehicleNameByVehicleCode(vehicleCode);
   }

   @Override
   public String getFirstCreateCustomerPartnerCode(String phone) {
      CustomerVO customerVO = new CustomerVO();
      customerVO.setPhone(phone);
      customerVO.setSource(DMSEnumsEntity.CustomerSource.PARTNER.getCode());//客户来源为自店创建
      return baseMapper.getFirstCreateCustomerPartnerCode(customerVO);
   }

   @Override
   public List<CustomerVO> getCustomerURM(String phone) {
      return baseMapper.getCustomerURM(phone);
   }

   @Override
   public PageInfo<CustomerVO> pageByOem(CustomerVO customerVO, Integer pageNum, Integer pageSize) {
      Map map = BeanTools.bean2map(customerVO);
      PageHelperPlus.startPage(pageNum,pageSize);
      List<CustomerVO> list = baseMapper.pageByOem(map);
      PageInfo<CustomerVO> pageInfo = new PageInfo<CustomerVO>(list);
      return pageInfo;
   }
}
